<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <title>Mentees: <%= controller.action_name %></title>
    <%= stylesheet_link_tag 'scaffold' %>
    <link href="/javascripts/ext/resources/css/ext-all.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" language="javascript" src="/javascripts/ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" language="javascript" src="/javascripts/ext/ext-all.js"></script>

    <script type="text/javascript" language="javascript" charset="utf-8">
      // <![CDATA[

    var toolbar = new Ext.Toolbar();
    Ext.onReady(function() {

        var viewport = new Ext.Viewport({
layout:'border',
items : [
{
region: 'north',
contentEl: 'head'
},
{
region: 'center',
contentEl: 'center',
// margins:'35 5 5 0',
layout: 'column',
tbar: toolbar
},
{
region: 'south',
contentEl: 'footer'
}
]
});
        toolbar.addButton({text: 'Login',
          handler: function () { console.log("Clicked"); window.location = window.location + "login";}  
          });
        toolbar.addButton({text: 'Sign up', 
          handler: function () { console.log("Clicked"); window.location = window.location + "signup";}  
          });
toolbar.addButton({text: 'Logout',
    handler: function () { console.log("Clicked"); window.location = window.location + "logout";}  
    });
}

)

function loggedInToolbar (tf, toolbar) {
  console.log(toolbar.items);
  if(tf){
    toolbar.items.itemAt(0).hide();
    toolbar.items.itemAt(1).hide();
  } else {
    toolbar.items.itemAt(2).hide();
  }
}

// ]]>
</script>
  </head>
  <body>
    <div id="container">

      <div id="head">
        <h1><a href="/">Mentorship!</a></h1>
      </div>

      <div id="north"></div>
      <div id="west"></div>
      <div id="east"></div>
      <div id="south"></div>
      <div id="center">

        <p style="color: green"><%= flash[:notice] %></p>

        <% unless current_user == :false %>
          <script type="text/javascript" language="javascript" charset="utf-8">
            // <![CDATA[

          Ext.onReady (function() {
          loggedInToolbar(true, toolbar);   
          })
          // ]]>
          </script>
        <% else %>
          <script type="text/javascript" language="javascript" charset="utf-8">
            // <![CDATA[
          Ext.onReady (function() {
              loggedInToolbar(false, toolbar);    
              })
// ]]>
</script>
        <% end %> 

        <%= yield  %>
      </div> <!-- center -->
      <div id="footer">
        Mentorship is a project of blah, blah, blah.
      </div>
    </div> <!-- container -->
  </body>
</html>
